<template>
	<jk-operation-card class="margin-bottom-10 width-100-percent fixed-operation-bar">
		<!--新增页-->
		<div v-if="pageType === 'add'" class="flex-start">
			<el-button type="info" plain icon="el-icon-back" size="small" class="item-gap" @click="onBackBtn">返回列表</el-button>
			<jk-save-button class="item-gap" :permission-prefix="permissionPrefix" @click="onClickBtn(null, 'save')"></jk-save-button>
		</div>
		<!--编辑页-->
		<div v-else-if="pageType === 'edit'" class="flex-start">
			<el-button type="info" plain icon="el-icon-back" size="small" class="item-gap" @click="onBackBtn">返回列表</el-button>
			<jk-update-button :permission-prefix="permissionPrefix" class="item-gap" @click="onClickBtn(null, 'update')"></jk-update-button>
		</div>
		<!--详情页-->
		<div v-else class="flex-start">
			<el-button type="info" plain icon="el-icon-back" size="small" class="item-gap" @click="onBackBtn">返回列表</el-button>
			<div class="item-gap"><el-button type="primary" icon="el-icon-edit" size="small" @click="onEditBtn">编辑</el-button></div>
		</div>
	</jk-operation-card>
</template>
<script>
    import { throttle } from '../../../../../utils/jk/jk-tool';
    import JkUpdateButton from '../../../../jk-components/jk-update-button';
    import JkSaveButton from '../../../../jk-components/jk-save-button';

    export default {
        components: { JkSaveButton, JkUpdateButton },
        props: {
            pageType: {
                type: String,
                default: 'detail'
            },
            permissionPrefix: {
                type: String,
                default: ''
            },
            auditState: {
                type: Number,
                default: null
            }
        },
        data() {
            return {};
        },
        methods: {
            onBackBtn() {
                this.$emit('on-back');
            },
            onEditBtn() {
                this.$store.dispatch('tagsView/delView', { path: this.$route.path });
                this.$emit('on-edit');
            },
            onClickBtn: throttle((arg, _this) => {
                _this.$emit('on-click', arg[0], arg[1]);
            }, 1000)
        }
    };
</script>
